<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<?php
	session_start();
	if (isset($_POST['login'])) {
		$name = $_POST['logName'];
		$pass = md5($_POST['logPass']);
		$db_connect = mysqli_connect("localhost" , "root" , "" , "tractor");
		$query = "select username, pass from users where username = \"$name\"";
		$result = mysqli_query($db_connect,$query);
		
		$row = mysqli_fetch_assoc($result);
		echo $row['pass'];
		echo "<br/>";
		echo $pass;
		if ($row['pass'] == $pass) {
			echo "Your logged";
			header("Location: index.php");
		}
		$_SESSION['name'] = $name;
		mysqli_close($db_connect);
	} 
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Cp1251">
<title>Insert title here</title>
</head>
	<?php
		if (isset($_POST['register'])) {
			header("Location: register.php");
		}
	?>
    <body>
    <form method="post" action="login.php">
    	Login:<input name="logName"><br/>
    	Passwor:<input type="password" name="logPass"><br/>
    	<input type="submit" value="Login" name="login">
    	<input type="submit" value="Register" name="register"> 
    </form>
    </body>
</html>